]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
userWidget: Handle non-square icons gracefully
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 10 Jul 2019 15:18:16 +0000 (17:18 +0200)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Mon, 29 Jul 2019 16:16:22 +0000 (16:16 +0000)
We currently assume that user icons are square, which is the case when
set by the users settings panel, but not enforced by AccountsService.

Handle that case by moving the pixel size back to the actor and using
an appropriate background-size style property of 'cover' (which means
the smallest dimension of the image is scaled to fit the desired size).

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1144

js/ui/userWidget.js

index 232a5f181e4a46ca2a69cfaa1b23def1d9dde00b..a24f37a3f8d240a7b67ddab9aa1cb754b8fd09a6 100644 (file)
@@ -46,9 +46,13 @@ var Avatar = class {
 
         if (iconFile) {
             this.actor.child = null;
+            let { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
+            this.actor.set_size(
+                this._iconSize * scaleFactor,
+                this._iconSize * scaleFactor);
             this.actor.style = `
                 background-image: url("${iconFile}");
-                background-size: ${this._iconSize}px`;
+                background-size: cover;`;
         } else {
             this.actor.style = null;
             this.actor.child = new St.Icon({ icon_name: 'avatar-default-symbolic',